public class Test {
    //汉诺塔问题
    public static void move(char pos1, char pos2) {
        System.out.print(pos1 + "->" + pos2 + " ");
    }
    /*
    pos1:起始位置
    pos2:中转位置
    pos3:目的位置
     */
    public static void Hanoi(int n, char pos1, char pos2, char pos3) {
        if(n == 1) {
            move(pos1, pos3);
        }else {
            Hanoi(n - 1, pos1, pos3, pos2);//将上边n-1个盘子通过pos3转移到pos2
            move(pos1, pos3);//将剩下的最后一个盘子从pos1直接转移到pos3
            Hanoi(n - 1, pos2, pos1, pos3);//将剩下的n-1个盘子通过pos1转移到pos3
        }
    }

    public static void main(String[] args) {
        Hanoi(3, 'A', 'B', 'C');
    }



    public static int fac(int n) {
        if(n == 0) {
            return 1;
        }
        return n * fac(n - 1);
    }

    public static void main6(String[] args) {
        System.out.println(fac(4));
    }
    public static double max(double x, double y, double z) {
        double max = x;
        if(y > x) {
            max = y;
        }
        if(z > x) {
            max = z;
        }
        return max;
    }
    public static int max(int x, int y) {
        if(x > y) {
            return x;
        }else {
            return y;
        }
    }

    public static void main5(String[] args) {
        System.out.println(max(2, 3));
        System.out.println(max(1.1, 2.2, 3.3));
    }

    public static double add(double x, double y, double z) {
        return x + y +z;
    }
    public static int add(int x, int y) {
        return x + y;
    }

    public static void main4(String[] args) {
        System.out.println(add(1, 2));
        System.out.println(add(1.1, 2.2, 3.3));
    }
    public static int fib(int n) {
        int fib1 = 0;
        int fib2 = 1;
        int fib3 = -1;
        for (int i = 3; i <= n; i++) {
            fib3 = fib1 + fib2;
            fib1 = fib2;
            fib2 = fib3;
        }
        return fib3;
    }

    public static void main3(String[] args) {
        System.out.println(fib(9));
    }

    public static int fac1(int n) {
        int result = 1;
        for (int i = 1; i <= n; i++) {
            result *= i;
        }
        return result;
    }

    public static void main2(String[] args) {
        int sum = 0;
        for (int i = 1; i <= 5; i++) {
            sum += fac(i);
        }
        System.out.println(sum);
    }

    public static double max2(double x, double y) {
        return x > y ? x : y;
    }
    public static double max3(double x, double y,double z) {
       double max = max2(x ,y);
       return max2(max, z);
    }
    public static void main1(String[] args) {
        System.out.println(max3(50, 10, 20));
    }
}
